package com.gold.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.gold.exception.ServiceException;
import com.gold.model.Bank;
import com.gold.model.Customer;
import com.gold.persist.CustomerMapper;
import com.gold.service.CustomerService;
import com.gold.util.Page;

@Service
public class CustomerServiceImpl implements CustomerService{

	@Resource
	CustomerMapper customerMapper;
	
	@Override
	public boolean delete(Integer modelPK) throws ServiceException {
		// TODO Auto-generated method stub
		return customerMapper.deleteByPrimaryKey(modelPK)>0?true:false;
	}

	@Override
	public boolean save(Customer model) throws ServiceException {
		// TODO Auto-generated method stub
		return customerMapper.insertSelective(model)>0?true:false;
	}

	@Override
	public Customer load(Integer modelPK) throws ServiceException {
		// TODO Auto-generated method stub
		return customerMapper.selectByPrimaryKey(modelPK);
	}

	@Override
	public List<Customer> findAll() throws ServiceException {
		// TODO Auto-generated method stub
		return customerMapper.getAll();
	}

	@Override
	public int countAll() throws ServiceException {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public boolean update(Customer model) throws ServiceException {
		// TODO Auto-generated method stub
		return customerMapper.updateByPrimaryKeySelective(model)>0?true:false;
	}

	@Override
	public Page<Customer> findByCondition(Page<Customer> page) {
		page.setResults(customerMapper.findByCondition(page));
        page.setTotalRecord(customerMapper.findCountByCondition(page));
        return page;
	}

}
